<template>
  <div class="print-container">

<!--      <Button class="btn-def" type="primary" size="large" @click="$router.go(-1)">关闭</Button>-->
      <Button class="btn-def" type="primary" size="large" @click="setPrint">打印</Button>
<!--    </div>-->
    <div id="review-print-box" v-show="false">
          <!-- 这里是模板信息 -->
          <p class="title">
            <span>个人信息</span>
          </p>
          <p>
            <span class="normal-text">姓名：</span>
            <span class="value-text">23423</span>
          </p>
          <p>
            <span class="normal-text">年龄</span>
            <span class="value-text">123</span>
          </p>

    </div>
  </div>
</template>
<script>
  export default {
    name:'Print',
    data () {
      return {
      }
    },
    mounted () {
    },
    methods: {
      setPrint() {
        var html = document.getElementById("review-print-box").innerHTML;
        var w = window.open(location.href);
        var style = w.document.createElement("style");
        style.type = "text/css";
        style.innerText = `打印内容元素的样式...`;
        w.document.getElementsByTagName("head").item(0).appendChild(style);
        w.document.body.innerHTML = html;
        w.document.close();
        w.print();
        w.close();
      }
    }
  }
</script>
